package com.tianqu.tms.entity;

import java.io.File;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import com.tianqu.tms.core.base.Logger;
import com.tianqu.tms.core.exception.TmsDaoException;
import com.tianqu.tms.core.util.CopyFile;
import com.tianqu.tms.core.util.DateUtil;
import com.tianqu.tms.core.util.ImageUtils;
import com.tianqu.tms.core.util.Registry;
import com.tianqu.tms.core.util.StringUtil;
import com.tianqu.tms.core.util.TmsConstants;
import com.tianqu.tms.dao.MemberDao;
import com.tianqu.tms.dao.TmsDao;
import com.tianqu.tms.dao.ViewListDao;
import com.tianqu.tms.dto.MemberDto;
import com.tianqu.tms.dto.MemberRentalLocationInfo;

/**
 * 会员信息处理entity类
 * 
 * @author tianshifu
 * 
 */

public class Member extends ViewListManager {
	private static Logger  logger = Logger.getLogger(Member.class);
	private int aucMargin;
	/**
	 * 
	 */
	private static final long serialVersionUID = -1285731075655659295L;

	private int memId;// 会员ID
	private String contractTime;
	private int contractType;
	private String memName;// 会员名 对应memberId

	/************* 第二次追加会员信息 ******************/

	private String realName;// 公司名称

	private String adrress;// 公司地址

	private String memberZipCode;// 公司邮编

	private String orgNo;// 组织机构代码

	private String businessNo;// 营业执照编号

	private String contactOwner;// 联系人
	
	private int fragileStickerFreePort;//易碎贴免费数量

	private String contactPhone;// 联系人电话

	private String legal;// 法人名称

	private String phone;// 法人电话

	private String cardNo;// 法人身份证号码

	private int registeredCapital;// 注册资金(元)

	private int operatingLife;// 经营年限(年)

	private int officeSpaceArea;// 办公场地面积(平米)

	private int annualTransactionVolume;// 年度交易量(元)

	private String margin;// 真实保证金(元)

	private String virtualMargin;// 虚拟保证金(元)
	/** 图片信息 **/
	private String orgPhoto;// 组织机构代码证图片

	private String businessPhoto;// 营业执照编号图片

	private String cardPhoto;// 法人身份证图片

	private String userId;// 登录名

	private int updateUserId;// 操作员ID
	private int insertUserId;
	private String settleName;//落户人姓名
	
	private String settleNo;//落户人身份证号
	
	private String settlePhone;//落户人电话

	private String shortName;//缩略名
	
	private String realNamePy;//商户名称拼音
	
	private String insertTime;//注册时间
	
	private String num;//序号
	
	private String identityRange;//长期有效识别道闸编号
	
	private String tmpIdentityRange;//临时有效识别道闸编号
	
	private int recharge;
	
	public int getRecharge() {
		return recharge;
	}

	public void setRecharge(int recharge) {
		this.recharge = recharge;
	}

	public int getAucMargin() {
		return aucMargin;
	}

	public void setAucMargin(int aucMargin) {
		this.aucMargin = aucMargin;
	}

	public List<Member> getCodem() {
		return codem;
	}

	public void setCodem(List<Member> codem) {
		this.codem = codem;
	}

	/*****************************************************/

	private String memberStatus;// 会员帐号状态 这个状态需要从用户表中获取
	
	private int cssFlag;//样式
	
	private int spacesNo;//车位数

	private int carPort;//车位数
	
	private int usedCarPort;//在停车位数
    private int freeCarPort;// 空闲车位数
	
	private String accessCardId;//积分卡编号
	
	private String floors;//车位所在楼层
	
	private String carPortInstr;//车位分配说明
	private String password;
	private String accessCardNo;//积分卡卡号
	private int cardScore;//累计积分
	private double integralRatio;//积分比例
    private int giftMargin;
    private int realMargin;
    private String recommend;
    private int memStatus;// 商户状态 
    
	/**
	 * 实例化codes表
	 * 
	 * @return
	 */
	private static Member instance;

	List<Member> codes = null;
	List<Member> codem = null;

	/**
	 * 加载Codes
	 * 
	 * @return
	 * @throws TmsDaoException
	 */
	public static Member getInstance() throws TmsDaoException {
			instance = new Member();
			instance.init();
			return instance;
	}

	/**
	 * 实例化Code
	 * 
	 * @throws TmsDaoException
	 */
	public void init() throws TmsDaoException {
		codes = new ArrayList<Member>();
		codem = new ArrayList<Member>();
		setCodes();
	}

	
	public String getPassword() {
		return password;
	}

	public void setPassword(String password) {
		this.password = password;
	}

	/**
	 * 获取Codes信息存在静态codes中
	 * 
	 * @throws TmsDaoException
	 */
	@SuppressWarnings("unchecked")
	public void setCodes() throws TmsDaoException {
		MemberDao mDao = (MemberDao) TmsDao.getInstance(TmsDao.TMS_MEMBER);
		List dtoList = mDao.findAllMemberInfo();
		List dtoListm = mDao.findAllMemberInfoM();
		for (int i = 0; i < dtoList.size(); i++) {
			MemberDto dto = (MemberDto) dtoList.get(i);
			Member entity = new Member();
			entity.setMemId(dto.getMemId());
			entity.setMemName(dto.getMemName());
			codes.add(entity);
		}
		for (int i = 0; i < dtoListm.size(); i++) {
			MemberDto dto = (MemberDto) dtoListm.get(i);
			Member entity = new Member();
			entity.setMemId(dto.getMemId());
			entity.setMemName(dto.getMemName());
			codem.add(entity);
		}
	}

	public Map<String, MemberDto> findAllMember() throws TmsDaoException {
		MemberDao mDao = (MemberDao) TmsDao.getInstance(TmsDao.TMS_MEMBER);
		Map<String, MemberDto> map = new HashMap<String, MemberDto>();
		List list = mDao.findAllMemberInfoM();
		for (Object dto : list) {
			MemberDto o = (MemberDto)dto;
			map.put(String.valueOf(o.getMemId()), o);
		}
		return map;
	}
	
	/**
	 * 查询出所有会员信息
	 * 
	 * @return
	 * @throws TmsDaoException
	 */
	@SuppressWarnings("unchecked")
	public List findAllMemInfo() throws TmsDaoException {

		List list = new ArrayList();// 用于存放会员信息
		Map map = null;
		for (int i = 0; i < codes.size(); i++) {
			Member entity = (Member) codes.get(i);
			map = new HashMap();
			map.put("memId", entity.getMemId());
			map.put("memName", entity.getMemName());
			list.add(map);
		}

		if (list.size() == 0) {
			return null;
		}
		return list;
	}

	/**
	 * add by huangwei st2
	 * @param status
	 * @return
	 * @throws TmsDaoException
	 */
	public List findAllMemInfo(int status) throws TmsDaoException {
		List list = new ArrayList();
		List<Member> members = findAllMemberInfo(status);
		Map map = null;
		for(Member member : members){
			map = new HashMap();
			map.put("memId", member.getMemId());
			map.put("memName", member.getRealName());
			list.add(map);
		}
		return list;
	}
	
	/**
	 *  huangwei st2
	 * @param status
	 * @return
	 * @throws TmsDaoException
	 */
	public List findAllMemInfo(String namePy,int userStatus) throws TmsDaoException {
		List list = new ArrayList();
		List<Member> members = findAllMemberInfo(namePy,userStatus);
		Map map = null;
		for(Member member : members){
			map = new HashMap();
			map.put("memId", member.getMemId());
			map.put("memName", member.getRealName());
			list.add(map);
		}
		return list;
	}
	
	/**
	 * 根据memberName获取memId
	 * @throws TmsDaoException 
	 * 
	 */
	public int getMemIdByMemName(String memName) throws TmsDaoException {
		
		if (!"".equals(memName) && memName != null) {
			for (int i = 0; i < codem.size(); i++) {
				Member member = (Member) codem.get(i);
				if (memName.equals(member.getMemName())) {
					return member.getMemId();
				}
			}
		}

		return 0;
	}

	/**
	 * 根据memid获取memname
	 * @throws TmsDaoException 
	 */
	public String getMemNameByMemId(int memId) throws TmsDaoException {
		
		for (int i = 0; i < codem.size(); i++) {
			Member entity = (Member) codem.get(i);
			if (memId == entity.getMemId()) {
				return entity.getMemName();
			}
		}

		return null;
	}

	/**
	 * 
	 * 添加会员信息
	 * 
	 * @throws TmsDaoException
	 */
	public void insetMemberInfoByEntity(Member entity,String sysPath) throws TmsDaoException {
		MemberDao mDao = (MemberDao) TmsDao.getInstance(TmsDao.TMS_MEMBER);
		MemberDto dto = new MemberDto();
		dto = setDtoFromEntityInfo(dto, entity);
	
		int memberId = entity.getMemId();
		
		dto.setMemId(memberId);
		
		//将image图片信息放到服务器上
		//对每个path进行处理   。。。【photo就是imgpath
		File outFile = null;
		File inFile = null;
		
		sysPath = sysPath.replace("/tmsweb", TmsConstants.BLANK);

		if(dto.getOrgPhoto()!=null && !"".equals(dto.getOrgPhoto()))
		{
			inFile = new File(sysPath+dto.getOrgPhoto());
			outFile = new File(ImageUtils.getImageDirectoryPath(Registry.getConfig(TmsConstants.UPLOAD_MEMBER_IMAGE_PATCH_KEY)+memberId+"/")+memberId+"_1.jpg");
			CopyFile.copy(inFile, outFile);	
			dto.setOrgPhoto(imgPath(dto.getOrgPhoto(), String.valueOf(memberId), "1"));
		}
		if(dto.getBusinessPhoto()!=null && !"".equals(dto.getBusinessPhoto()))
		{
			inFile = new File(sysPath+dto.getBusinessPhoto());
			
			outFile = new File(sysPath + Registry.getConfig(TmsConstants.UPLOAD_MEMBER_IMAGE_PATCH_KEY)+"/"+memberId+"/");
			if (!outFile.exists()) {
				outFile.mkdirs();
			}
			outFile = new File(outFile+"/"+memberId+"_2.jpg");
			
			CopyFile.copy(inFile, outFile);	
			
			dto.setBusinessPhoto(imgPath(dto.getBusinessPhoto(), String.valueOf(memberId), "2"));

		}
		if(dto.getCardPhoto()!=null && !"".equals(dto.getCardPhoto()))
		{
			inFile = new File(sysPath+dto.getCardPhoto());
			
			outFile = new File(sysPath + Registry.getConfig(TmsConstants.UPLOAD_MEMBER_IMAGE_PATCH_KEY)+"/"+memberId+"/");
			if (!outFile.exists()) {
				outFile.mkdirs();
			}
			outFile = new File(outFile+"/"+memberId+"_3.jpg");
			
			CopyFile.copy(inFile, outFile);	
			
			dto.setCardPhoto(imgPath(dto.getCardPhoto(), String.valueOf(memberId), "3"));

		}
		if(dto.getMemberZipCode()!=null && !"".equals(dto.getMemberZipCode()))
		{
			inFile = new File(sysPath+dto.getMemberZipCode());
			
			outFile = new File(sysPath + Registry.getConfig(TmsConstants.UPLOAD_MEMBER_IMAGE_PATCH_KEY)+"/"+memberId+"/");
			if (!outFile.exists()) {
				outFile.mkdirs();
			}
			outFile = new File(outFile+"/"+memberId+"_5.jpg");
			
			CopyFile.copy(inFile, outFile);	
			
			dto.setMemberZipCode(imgPath(dto.getMemberZipCode(), String.valueOf(memberId), "5"));

		}
		
		//这个地方需要对图片路径进行转换
		
		mDao.insetMemberInfoByDto(dto);
	}

	/**
	 * 处理存入数据库中的图片路径
	 */
	private String imgPath(String path,String memberId,String imgKey){
		return ImageUtils.getImageUrl(Registry.getConfig(TmsConstants.UPLOAD_MEMBER_IMAGE_PATCH_KEY) +memberId+"/"+memberId+"_"+imgKey+".jpg") ;	
	}	
	
	
	/**
	 * 
	 * 将entity数据set到dto中
	 */
	public MemberDto setDtoFromEntity(MemberDto dto, Member entity) {
		dto.setMemId(entity.getMemId());
		dto.setRealName(entity.getRealName());
		dto.setAdrress(entity.getAdrress());
		dto.setMemberZipCode(entity.getMemberZipCode());
		dto.setOrgNo(entity.getOrgNo());
		dto.setBusinessNo(entity.getBusinessNo());
		dto.setContactOwner(entity.getContactOwner());
		dto.setContactPhone(entity.getContactPhone());
		dto.setLegal(entity.getLegal());
		dto.setPhone(entity.getPhone());
		dto.setCardNo(entity.getCardNo());
		dto.setAucMargin(entity.getAucMargin());
		dto.setRegisteredCapital(entity.getRegisteredCapital());
		dto.setOperatingLife(entity.getOperatingLife());
		dto.setOfficeSpaceArea(entity.getOfficeSpaceArea());
		dto.setAnnualTransactionVolume(entity.getAnnualTransactionVolume());
		if(entity.getMargin()!=null && !"".equals(entity.getMargin()))
		{
			dto.setMargin(Integer.parseInt(entity.getMargin()));
		}else{
			dto.setMargin(0);
		}
		if(entity.getVirtualMargin()!=null && !"".equals(entity.getVirtualMargin()))
		{
			dto.setVirtualMargin(Integer.parseInt(entity.getVirtualMargin()));
		}else{
			dto.setVirtualMargin(0);
		}
		dto.setCarPort(entity.getCarPort());//车位数
		dto.setUserId(entity.getUserId());
		dto.setUpdateUserId(entity.getUpdateUserId());
		dto.setOrgPhoto(entity.getOrgPhoto());
		dto.setBusinessPhoto(entity.getBusinessPhoto());
		dto.setCardPhoto(entity.getCardPhoto());
		dto.setInsertUserId(entity.getInsertUserId());
		dto.setUpdateUserId(entity.getUpdateUserId());
		dto.setAccessCardId(entity.getAccessCardId());
		dto.setAccessCardNo(entity.getAccessCardNo());
		dto.setSettleName(entity.getSettleName());
		dto.setSettleNo(entity.getSettleNo());
		dto.setSettlePhone(entity.getSettlePhone());
		dto.setFloors(entity.getFloors());
		dto.setCarPortInstr(entity.getCarPortInstr());
		//workload:3.1.4
		dto.setOrgNo(entity.getOrgNo());
		dto.setShortName(entity.getShortName());
		dto.setCarPort(entity.getCarPort());
		dto.setMemberZipCode(entity.getMemberZipCode());
		dto.setIntegralRatio(entity.getIntegralRatio());
		dto.setAccessCardId(entity.getAccessCardId());
		dto.setAccessCardNo(entity.getAccessCardNo());
		return dto;
	}
	/**
	 * 
	 * 将entity数据set到dto中
	 */
	public MemberDto setDtoFromEntityInfo(MemberDto dto, Member entity) {
		dto.setMemName(entity.getMemName());
		dto.setMemId(entity.getMemId());
		dto.setRealName(entity.getRealName());
		dto.setShortName(entity.getShortName());
		dto.setRealNamePy(entity.getRealNamePy());
		dto.setBusinessNo(entity.getBusinessNo());
		dto.setAccessCardId(entity.getAccessCardId());
		dto.setAccessCardNo(entity.getAccessCardNo());
		dto.setAdrress(entity.getAdrress());
		dto.setContactOwner(entity.getContactOwner());
		dto.setContactPhone(entity.getContactPhone());
		dto.setLegal(entity.getLegal());
		dto.setPhone(entity.getPhone());
		dto.setRegisteredCapital(entity.getRegisteredCapital());
		dto.setCardNo(entity.getCardNo());
		dto.setSettlePhone(entity.getSettlePhone());
		dto.setOrgNo(entity.getOrgNo());
		dto.setCardPhoto(entity.getCardPhoto());
		dto.setOrgPhoto(entity.getOrgPhoto());
		dto.setBusinessPhoto(entity.getBusinessPhoto());
		dto.setMemberZipCode(entity.getMemberZipCode());
		dto.setCarPortInstr(entity.getCarPortInstr());
		dto.setCarPort(entity.getCarPort());//车位数
		dto.setUsedCarPort(entity.getUsedCarPort());
		dto.setAnnualTransactionVolume(entity.getAnnualTransactionVolume());
		dto.setFragileStickerFreePort(entity.getFragileStickerFreePort());
		dto.setRecommend(entity.getRecommend());
		dto.setAucMargin(entity.getAucMargin());
		if(entity.getMargin()!=null && !"".equals(entity.getMargin()))
		{
			dto.setMargin(Integer.parseInt(entity.getMargin()));
		}else{
			dto.setMargin(0);
		}
		if(entity.getVirtualMargin()!=null && !"".equals(entity.getVirtualMargin()))
		{
			dto.setVirtualMargin(Integer.parseInt(entity.getVirtualMargin()));
		}else{
			dto.setVirtualMargin(0);
		}
		dto.setRealMargin(entity.getRealMargin());
		dto.setGiftMargin(entity.getGiftMargin());
		dto.setCardScore(entity.getCardScore());
		dto.setIntegralRatio(entity.getIntegralRatio());
		dto.setUserId(entity.getUserId());
		dto.setInsertUserId(entity.getInsertUserId());
		dto.setUpdateUserId(entity.getUpdateUserId());
		dto.setFloors(entity.getFloors());

		return dto;
	}
	
	/**
	 * add by huangwei st2
	 * @param userStatus
	 * @return
	 * @throws TmsDaoException
	 */
	public List<Member> findAllMemberInfo(int userStatus) throws TmsDaoException {
		MemberDao mDao = (MemberDao) TmsDao.getInstance(TmsDao.TMS_MEMBER, getPageNo(), getMaxIndex(), getSortKey(), isAsc());
		ViewListDao idao = (ViewListDao) TmsDao.getViewListDao((TmsDao) mDao, TmsDao.TMS_MEMBER); 
		List<MemberDto> list = mDao.findMemberList();
		List<Member> r = new ArrayList<Member>();
		for(MemberDto dto : list){
			if(dto.getMemStatus() != userStatus) continue;
			r.add(setEntityFromDto(new Member(), dto));
		}
		return r;
	}
	
	public List<Member> findAllMemberInfo(String namePy,int userStatus) throws TmsDaoException {
		MemberDao mDao = (MemberDao) TmsDao.getInstance(TmsDao.TMS_MEMBER, getPageNo(), getMaxIndex(), getSortKey(), isAsc());
		ViewListDao idao = (ViewListDao) TmsDao.getViewListDao((TmsDao) mDao, TmsDao.TMS_MEMBER); 
		List<MemberDto> list = mDao.findMemberList(namePy);
		List<Member> r = new ArrayList<Member>();
		for(MemberDto dto : list){
			if(dto.getMemStatus() != userStatus) continue;
			r.add(setEntityFromDto(new Member(), dto));
		}
		return r;
	}
	
	/**
	 * 获取所有的会员信息
	 * 
	 * @throws TmsDaoException
	 * 
	 */

	public List<Member> findAllMemberInfo(String memberId,String flag) throws TmsDaoException {
		MemberDao mDao = (MemberDao) TmsDao.getInstance(TmsDao.TMS_MEMBER,
				getPageNo(), getMaxIndex(), getSortKey(), isAsc());
		ViewListDao idao = (ViewListDao) TmsDao.getViewListDao((TmsDao) mDao,
				TmsDao.TMS_MEMBER); 
		List<MemberDto> list = mDao.findMemberInfoList(memberId,flag);
		List<Member> entityList = new ArrayList<Member>();

		Member entity = null;
		// 循环将dto数据set到entity中 设定一个参数 用来表显页面的样式
		if (list.size() > 0) {

			for (int i = 0; i < list.size(); i++) {
				MemberDto dto = list.get(i);
				entity = new Member();
				entity.setNum(String.valueOf(i+1));
				entity.setMemId(dto.getMemId());
				entity.setRealName(dto.getShortName());
				entity.setContactOwner(dto.getContactOwner());
				entity.setContactPhone(dto.getContactPhone());
				entity.setLegal(dto.getLegal());
				entity.setPhone(dto.getPhone());
				SimpleDateFormat fm = new SimpleDateFormat("yyyy-MM-dd");
				if(dto.getInsertTime() != null){
					entity.setInsertTime(fm.format(dto.getInsertTime()));
				}
				if (dto.getMemStatus() == 1) {
					// 正常 删除 禁用
					entity.setMemberStatus("正常");
				}
				if (dto.getMemStatus() == 3) {
					entity.setMemberStatus("禁用");
				}
				if(i%2 == 0){
					entity.setCssFlag(1);
				}else{
					entity.setCssFlag(2);
				}

				entityList.add(entity);
			}
		}
		setPagingInfo(idao);
		return entityList;
	}
	
	/**
	 * 获取所有的会员信息
	 * 
	 * @throws TmsDaoException
	 * 
	 */

	public List<Member> findAllSMSMemberInfo() throws TmsDaoException {
		MemberDao mDao = (MemberDao) TmsDao.getInstance(TmsDao.TMS_MEMBER);
		List<MemberDto> list = mDao.sendSMSMemberList();
		List<Member> entityList = new ArrayList<Member>();
		
		// 循环将dto数据set到entity中 设定一个参数 用来表显页面的样式
		if (list.size() > 0) {

			for (int i = 0; i < list.size(); i++) {
				MemberDto dto = list.get(i);
				Member entity = new Member();
				
				entity.setContactPhone(dto.getContactPhone());

				entityList.add(entity);
			}
		}
		return entityList;
	}

	/***
	 * 
	 * 
	 * 根据会员ID查询会员信息
	 * 
	 * @throws TmsDaoException
	 */
	public Member findMemberInfoByMemId(String memberID) throws TmsDaoException {
		MemberDao mDao = (MemberDao) TmsDao.getInstance(TmsDao.TMS_MEMBER);
		MemberDto dto = mDao.findMemberInfoByMemId(memberID);
		// 将dto信息set到entity中
		Member entity = new Member();
		if(dto!=null)
		{
			entity = new Member();
			entity = setEntityFromDtoInfo(entity, dto);
		}
		return entity;
	}

	/***
	 * 
	 * 
	 * 根据会员ID查询已登记库存数量
	 * 
	 * @throws TmsDaoException
	 */
	public int findRegistedCount(String memberID) throws TmsDaoException {
		MemberDao mDao = (MemberDao) TmsDao.getInstance(TmsDao.TMS_MEMBER);
		return mDao.findRegistedCount(memberID);
	}
	
	public MemberRentalLocationInfo findMemberRentalLocationInfoCount(String serials) throws TmsDaoException {
		MemberDao mDao = (MemberDao) TmsDao.getInstance(TmsDao.TMS_MEMBER);
		if(StringUtil.isNullOrBlank(serials)) {
			MemberRentalLocationInfo r = new MemberRentalLocationInfo();
			r.setUnusedAnnualTransactionVolume("0");
			r.setUnusedCarPort("0");
			r.setUsedAnnualTransactionVolume("0");
			r.setUsedCarPort("0");
			return r;
		}else  return mDao.findMemberRentalLocationInfoCount(serials);
	}
	
	public MemberRentalLocationInfo findMemberLocationInfoCount(String serials) throws TmsDaoException {
		MemberDao mDao = (MemberDao) TmsDao.getInstance(TmsDao.TMS_MEMBER);
		if(StringUtil.isNullOrBlank(serials)) {
			MemberRentalLocationInfo r = new MemberRentalLocationInfo();
			r.setUnusedAnnualTransactionVolume("0");
			r.setUnusedCarPort("0");
			r.setUsedAnnualTransactionVolume("0");
			r.setUsedCarPort("0");
			return r;
		} else return mDao.findMemberLocationInfoCount(serials);
	}
	
	/**
	 * 根据MemberId载入登记楼层
	 * @param memberId
	 * @return
	 * @throws TmsDaoException 
	 */
	public Member findCarScoreByMemberId(String memberId) throws TmsDaoException{
		MemberDao mDao = (MemberDao) TmsDao.getInstance(TmsDao.TMS_MEMBER);
		MemberDto dto = mDao.loadCarScore(memberId);
		Member member = new Member();
		member.setCarPort(dto.getCarPort());
		member.setFragileStickerFreePort(dto.getFragileStickerFreePort());
		//add by huangheli at 20150803 start
		member.setUsedCarPort(dto.getUsedCarPort());
		//add by huangheli at 20150803 end
		//add by huangheli at 20151012 start
		member.setIntegralRatio(dto.getIntegralRatio());
		//add by huangheli at 20151012 end
		member.setFloors(dto.getFloors());
		member.setCarPortInstr(dto.getCarPortInstr());
		member.setContactOwner(dto.getContactOwner());
		member.setContactPhone(dto.getContactPhone());
		member.setCardScore(dto.getCardScore());
		member.setMemId(dto.getMemId());
		member.setMemName(dto.getMemName());
		member.setPassword(dto.getPassword());
		//add by mufeiyu at 20161222 end
		member.setAnnualTransactionVolume(dto.getAnnualTransactionVolume());
		member.setVirtualMargin(String.valueOf(dto.getVirtualMargin()));
		return member;
	}
	
	/**
	 * 
	 * 根据登录id（USERID）查询会员基本信息
	 * 
	 * @throws TmsDaoException
	 */
	public Member findMemberInfoByUserId(String userId) throws TmsDaoException {
		MemberDao mDao = (MemberDao) TmsDao.getInstance(TmsDao.TMS_MEMBER);

		MemberDto dto = mDao.findMemberInfoByUserId(userId);

		// 将dto信息set到entity中
		Member entity = new Member();
		if(dto != null){
			entity = setEntityFromDto(entity, dto);
		}

		return entity;
	}
	
	
	/**
	 *库存统计中载入所有会员
	 * @param memId
	 * @return
	 * @throws TmsDaoException 
	 */
	public Member getMember(String memId) throws TmsDaoException{
		Member entity = new Member();
		MemberDao mDao = (MemberDao) TmsDao.getInstance(TmsDao.TMS_MEMBER);
		MemberDto dto = (MemberDto)mDao.getMember(memId);
		entity.setRealName(dto.getRealName());
		entity.setShortName(dto.getShortName());
		entity.setRecommend(dto.getRecommend());
		entity.setAccessCardId(dto.getAccessCardId());
		entity.setCarPort(dto.getCarPort());
		entity.setUsedCarPort(dto.getUsedCarPort());
		entity.setUserId(dto.getUserId());
		entity.setMemId(dto.getMemId());
		entity.setAccessCardId(dto.getAccessCardId());
		entity.setAccessCardNo(dto.getAccessCardNo());
		entity.setContactOwner(dto.getContactOwner());
		entity.setContactPhone(dto.getContactPhone());
		return entity;
	}
	public void updateMemberVirtualMargin(String memberId, int virtualMargin) throws TmsDaoException{
		MemberDao mDao = (MemberDao) TmsDao.getInstance(TmsDao.TMS_MEMBER);
		mDao.updateMemberVirtualMargin(memberId,virtualMargin);
	}
    public void updateMemberVirtualMarginByUserId(String userId, int virtualMargin) throws TmsDaoException{
        MemberDao mDao = (MemberDao) TmsDao.getInstance(TmsDao.TMS_MEMBER);
        mDao.updateMemberVirtualMarginByUserId(userId,virtualMargin);
    }

	/**
	 * 
	 * 将dto信息set到entity中
	 */
	private Member setEntityFromDto(Member entity, MemberDto dto) {	

		entity.setMemId(dto.getMemId());
		entity.setRealName(dto.getRealName());
		entity.setAdrress(dto.getAdrress());
		entity.setMemberZipCode(dto.getMemberZipCode());
		entity.setOrgNo(dto.getOrgNo());
		entity.setBusinessNo(dto.getBusinessNo());
		entity.setContactOwner(dto.getContactOwner());
		entity.setContactPhone(dto.getContactPhone());
		entity.setLegal(dto.getLegal());
		entity.setPhone(dto.getPhone());
		entity.setCardNo(dto.getCardNo());
		entity.setRegisteredCapital(dto.getRegisteredCapital());
		entity.setOperatingLife(dto.getOperatingLife());
		entity.setOfficeSpaceArea(dto.getOfficeSpaceArea());
		entity.setAnnualTransactionVolume(dto.getAnnualTransactionVolume());
		entity.setMargin(String.valueOf(dto.getMargin()));
		entity.setVirtualMargin(String.valueOf(dto.getVirtualMargin()));
		entity.setUserId(dto.getUserId());
		entity.setUpdateUserId(dto.getUpdateUserId());
		entity.setOrgPhoto(dto.getOrgPhoto());// 组织机构代码证图片
		entity.setBusinessPhoto(dto.getBusinessPhoto());// 营业执照编号图片
		entity.setCardPhoto(dto.getCardPhoto());// 法人身份证图片
		entity.setSpacesNo(dto.getSpacesNo());//车位数
		entity.setCarPort(dto.getCarPort());
		entity.setUsedCarPort(dto.getUsedCarPort());
		entity.setFloors(dto.getFloors());
		entity.setCarPortInstr(dto.getCarPortInstr());
		entity.setSettleName(dto.getSettleName());
		entity.setSettleNo(dto.getSettleNo());
		entity.setSettlePhone(dto.getSettlePhone());
		entity.setAccessCardId(dto.getAccessCardId());
		entity.setAccessCardNo(dto.getAccessCardNo());
		entity.setCardScore(dto.getCardScore());
		entity.setIntegralRatio(dto.getIntegralRatio());
		entity.setShortName(dto.getShortName());
		entity.setMemberZipCode(dto.getMemberZipCode());
		entity.setShortName(dto.getShortName());
		entity.setRealMargin(dto.getRealMargin());
		entity.setGiftMargin(dto.getGiftMargin());
		entity.setRecommend(dto.getRecommend());
		entity.setAucMargin(dto.getAucMargin());
		return entity;
	}
	/**
	 * 
	 * 将dto信息set到entity中
	 */
	private Member setEntityFromDtoInfo(Member entity, MemberDto dto) {	

		entity.setMemId(dto.getMemId());
		entity.setRealName(dto.getRealName());
		entity.setShortName(dto.getShortName());
		entity.setRealNamePy(dto.getRealNamePy());
		entity.setMemStatus(dto.getMemStatus());
		entity.setInsertTime(DateUtil.DateToString11(dto.getInsertTime()));
		entity.setContractType(dto.getContractType());
		if(dto.getContractTime()!=null) entity.setContractTime(DateUtil.DateToString11(dto.getContractTime()));
		else entity.setContractTime("");
		entity.setContactOwner(dto.getContactOwner());
		entity.setContactPhone(dto.getContactPhone());
		entity.setLegal(dto.getLegal());
		entity.setCardNo(dto.getCardNo());
		entity.setSettlePhone(dto.getSettlePhone());
		entity.setOrgNo(dto.getOrgNo());
		entity.setPhone(dto.getPhone());
		entity.setRegisteredCapital(dto.getRegisteredCapital());
		entity.setOrgPhoto(dto.getOrgPhoto());// 组织机构代码证图片
		entity.setBusinessPhoto(dto.getBusinessPhoto());// 营业执照编号图片
		entity.setCardPhoto(dto.getCardPhoto());// 法人身份证图片
		entity.setMemberZipCode(dto.getMemberZipCode());
		entity.setCarPortInstr(dto.getCarPortInstr());
		entity.setUserId(dto.getUserId());
		entity.setPassword(dto.getPassword());
		entity.setCarPort(dto.getCarPort());
		entity.setFragileStickerFreePort(dto.getFragileStickerFreePort());
		entity.setAnnualTransactionVolume(dto.getAnnualTransactionVolume());
		entity.setRecommend(dto.getRecommend());
		entity.setBusinessNo(dto.getBusinessNo());
		entity.setUsedCarPort(dto.getUsedCarPort());
		entity.setAucMargin(dto.getAucMargin());
		entity.setMargin(String.valueOf(dto.getMargin()));
		entity.setVirtualMargin(String.valueOf(dto.getVirtualMargin()));
		entity.setRealMargin(dto.getRealMargin());
		entity.setGiftMargin(dto.getGiftMargin());
		entity.setCardScore(dto.getCardScore());
		entity.setIntegralRatio(dto.getIntegralRatio());
		entity.setFloors(dto.getFloors());
		entity.setAccessCardId(dto.getAccessCardId());
		entity.setAccessCardNo(dto.getAccessCardNo());
		entity.setIdentityRange(dto.getIdentityRange());
		entity.setTmpIdentityRange(dto.getTmpIdentityRange());
		entity.setFreeCarPort(dto.getCarPort()-dto.getUsedCarPort());
		return entity;
	}

	/**
	 * 
	 * 更新会员账户信息
	 * 
	 * @throws TmsDaoException
	 */
	public void updateAccountInfoByMemId(Member entity) throws TmsDaoException {
		MemberDao mDao = (MemberDao) TmsDao.getInstance(TmsDao.TMS_MEMBER);
		MemberDto dto = new MemberDto();
		dto = setDtoFromEntity(dto, entity);
		mDao.updateAccountInfoByMemId(dto);
	}

	/**
	 * 
	 * 更新会员基本信息
	 * 
	 * @throws TmsDaoException
	 */
	public void updateMemberBaseInfoByMemId(Member entity,String sysPath)
			throws TmsDaoException {
		MemberDao mDao = (MemberDao) TmsDao.getInstance(TmsDao.TMS_MEMBER);
		MemberDto dto = new MemberDto();
		dto = setDtoFromEntityInfo(dto, entity);
		dto.setUpdateUserId(entity.getUpdateUserId());
		
		//将image图片信息放到服务器上
		//对每个path进行处理
		File outFile = null;
		File inFile = null;
		
		sysPath = sysPath.replace("/tmsweb", "");

		if(dto.getOrgPhoto()!=null && !"".equals(dto.getOrgPhoto()))
		{
			inFile = new File(sysPath+dto.getOrgPhoto());
			if(dto.getOrgPhoto().indexOf("carImageTmp") != -1)
			{
				outFile = new File(ImageUtils.getImageDirectoryPath(Registry.getConfig(TmsConstants.UPLOAD_MEMBER_IMAGE_PATCH_KEY)+dto.getMemId()+"/")+dto.getMemId()+"_1.jpg");
				CopyFile.copy(inFile, outFile);					
			}
			dto.setOrgPhoto(imgPath(dto.getOrgPhoto(), String.valueOf(dto.getMemId()), "1"));
		}
		if(dto.getBusinessPhoto()!=null && !"".equals(dto.getBusinessPhoto()))
		{
			inFile = new File(sysPath+dto.getBusinessPhoto());
			if(dto.getBusinessPhoto().indexOf("carImageTmp") != -1)
			{			
				outFile = new File(sysPath + Registry.getConfig(TmsConstants.UPLOAD_MEMBER_IMAGE_PATCH_KEY)+"/"+dto.getMemId()+"/");
				if (!outFile.exists()) {
					outFile.mkdirs();
				}
				outFile = new File(outFile+"/"+dto.getMemId()+"_2.jpg");
				
				CopyFile.copy(inFile, outFile);			
			}
			dto.setBusinessPhoto(imgPath(dto.getBusinessPhoto(), String.valueOf(dto.getMemId()), "2"));

		}
		if(dto.getCardPhoto()!=null && !"".equals(dto.getCardPhoto()))
		{
			inFile = new File(sysPath+dto.getCardPhoto());
			if(dto.getCardPhoto().indexOf("carImageTmp") != -1)
			{			
				outFile = new File(sysPath + Registry.getConfig(TmsConstants.UPLOAD_MEMBER_IMAGE_PATCH_KEY)+"/"+dto.getMemId()+"/");
				if (!outFile.exists()) {
					outFile.mkdirs();
				}
				outFile = new File(outFile+"/"+dto.getMemId()+"_3.jpg");
				
				CopyFile.copy(inFile, outFile);		
			}
			
			dto.setCardPhoto(imgPath(dto.getCardPhoto(), String.valueOf(dto.getMemId()), "3"));
		}
		if(dto.getMemberZipCode()!=null && !"".equals(dto.getMemberZipCode()))
		{
			inFile = new File(sysPath+dto.getMemberZipCode());
			if(dto.getMemberZipCode().indexOf("carImageTmp") != -1)
			{			
				outFile = new File(sysPath + Registry.getConfig(TmsConstants.UPLOAD_MEMBER_IMAGE_PATCH_KEY)+"/"+dto.getMemId()+"/");
				if (!outFile.exists()) {
					outFile.mkdirs();
				}
				outFile = new File(outFile+"/"+dto.getMemId()+"_5.jpg");
				
				CopyFile.copy(inFile, outFile);		
			}
			
			dto.setMemberZipCode(imgPath(dto.getCardPhoto(), String.valueOf(dto.getMemId()), "5"));
		}
		
		// 执行更新操作
		mDao.updateBaseMemberInfoByMemId(dto);
	}

	/**
	 * 积分卡更新
	 * @param memId
	 * @throws TmsDaoException 
	 */
	public void updateIntegralcard(Member mem) throws TmsDaoException{
		MemberDao mDao = (MemberDao) TmsDao.getInstance(TmsDao.TMS_MEMBER);
		MemberDto dto = new MemberDto();
		dto.setAccessCardId(mem.getAccessCardId());
		dto.setAccessCardNo(mem.getAccessCardNo());
		dto.setMemName(mem.getMemName());
		dto.setUpdateUserId(mem.getUpdateUserId());
		mDao.updateIntegralcard(dto);
	}

	public List<MemberDto> findRecommendMember(int recommend) throws TmsDaoException{
		MemberDao mDao = (MemberDao) TmsDao.getInstance(TmsDao.TMS_MEMBER);
		return mDao.findRecommendMember(recommend);
	}
	
	/**
	 * 库存统计载入所有会员
	 * @return
	 * @throws TmsDaoException 
	 */
	@SuppressWarnings("unchecked")
	public List lodaAllMember() throws TmsDaoException{
		List allMemberList = new ArrayList();
		Member mem = Member.getInstance();
		allMemberList = mem.lodaAllMember();
		for(int i=1;i<allMemberList.size();i++){
			MemberDto dto = (MemberDto)allMemberList.get(i);
			Member entity = new Member();
			entity.setMemId(dto.getMemId());
			entity.setMemName(dto.getMemName());
			entity.setAccessCardId(dto.getAccessCardId());
			entity.setCarPort(dto.getCarPort());
			entity.setUsedCarPort(dto.getUsedCarPort());
			allMemberList.add(entity);
		}
		return allMemberList;
	}
	
	/**
	 * 或许更新时间
	 * 
	 * @return
	 * @throws TmsDaoException 
	 */
	public int findUpdateTimeByMemberId(String memberId,String inTime) throws TmsDaoException
	{
		MemberDao mDao = (MemberDao) TmsDao.getInstance(TmsDao.TMS_MEMBER);
		
		int updateTime = 0;
		
		updateTime = mDao.findUpdateTimeByMemberId(memberId,inTime);
		
		return updateTime;
	}
	
	/**
	 * 是否存在member
	 * @param memberId
	 * @return
	 * @throws TmsDaoException
	 */
	public boolean hasMember(String memberId) throws TmsDaoException{
        MemberDao mDao = (MemberDao) TmsDao.getInstance(TmsDao.TMS_MEMBER);
		int bsflag = mDao.findMemberInfoByMemberId(memberId);
		return bsflag == 0;
	}
	
	/**
	 * 判断商户名称是否重复
	 * @param realName
	 * @return
	 * @throws TmsDaoException
	 */
	public boolean isRepeatMemberName(String memberName,int type) throws TmsDaoException{
        MemberDao mDao = (MemberDao) TmsDao.getInstance(TmsDao.TMS_MEMBER);
        boolean result = mDao.isRepeatMemberName(memberName,type);
		return result;
	}
	
	/**
	 * 根据memberID查询会员信息是否存在
	 * 
	 * @return
	 * @throws TmsDaoException     
	 */
	public int findMemberInfoByMemberId(String memberId) throws TmsDaoException
	{
		MemberDao mDao = (MemberDao) TmsDao.getInstance(TmsDao.TMS_MEMBER);
		
		int bsflag = 0;
		
		bsflag = mDao.findMemberInfoByMemberId(memberId);
		
		return bsflag;
	}
	
	/**
	 * 判断是否有相同的积分卡编号
	 * @param accessCardId
	 * @return
	 * @throws TmsDaoException 
	 */
	public int findMemberByAccessCardId(String accessCardId) throws TmsDaoException{
		int flag = 1;
		MemberDao mDao = (MemberDao) TmsDao.getInstance(TmsDao.TMS_MEMBER);
		flag = mDao.findMemberByAccessCardId(accessCardId);
		return flag;
	}
	
	/**
	 * 判断是否有相同的积分卡卡号
	 * @param accessCardNo
	 * @return
	 * @throws TmsDaoException
	 */
	public int findMemberByAccessCardNo(String accessCardNo)throws TmsDaoException{
		int flag = 1;
		MemberDao mDao = (MemberDao) TmsDao.getInstance(TmsDao.TMS_MEMBER);
		flag = mDao.findMemberByAccessCardNo(accessCardNo);
		return flag;
	}
	/**
	 * 积分管理
	 * @return
	 * @throws TmsDaoException 
	 */
	public Member getIntegralManagementInfo(String accid) throws TmsDaoException
	{
		if(StringUtil.isNullOrBlank(accid)) return null;
		MemberDao mDao = (MemberDao) TmsDao.getInstance(TmsDao.TMS_MEMBER);
		MemberDto dto = new MemberDto();
		Member member = null;
		dto = mDao.getIntegralManagementInfo(accid);
		if(dto!=null)
		{
			member = new Member();
			member = setEntityFromDto(member, dto);
		}
		return member;
	}
	
	/**
	 * 更新会员积分at积分登记
	 * @param entity
	 * @throws TmsDaoException
	 */
	public void updateMarginInfo(Member entity) throws TmsDaoException
	{
		MemberDao mDao = (MemberDao) TmsDao.getInstance(TmsDao.TMS_MEMBER);
		MemberDto dto = new MemberDto();
		dto.setVirtualMargin(Integer.parseInt(entity.getVirtualMargin()));
		dto.setRealMargin(entity.getRealMargin());
		dto.setGiftMargin(entity.getGiftMargin());
		dto.setUpdateUserId(entity.getUpdateUserId());
		dto.setAccessCardNo(entity.getAccessCardNo());
		mDao.updateMarginInfo(dto);
	}
	/**
	 * 更新会员积分at积分登记
	 * @param entity
	 * @throws TmsDaoException
	 */
	public void updateMarginInfoByAccessCardNo(Member entity) throws TmsDaoException
	{
		MemberDao mDao = (MemberDao) TmsDao.getInstance(TmsDao.TMS_MEMBER);
		MemberDto dto = new MemberDto();
		dto.setVirtualMargin(Integer.parseInt(entity.getVirtualMargin()));
		dto.setRealMargin(entity.getRealMargin());
		dto.setUpdateUserId(entity.getUpdateUserId());
		dto.setAccessCardNo(entity.getAccessCardNo());
		dto.setRecharge(entity.getRecharge());
		mDao.updateMarginInfoByAccessCardNo(dto);
	}
	
	/**
	 * 更新会员积分at积分登记
	 * @param entity
	 * @throws TmsDaoException
	 */
	public void updateIntegralCardScore(Member entity) throws TmsDaoException
	{
		MemberDao mDao = (MemberDao) TmsDao.getInstance(TmsDao.TMS_MEMBER);
		MemberDto dto = new MemberDto();
		dto.setMemId(entity.getMemId());
		dto.setCardScore(entity.getCardScore());
		dto.setUpdateUserId(entity.getUpdateUserId());
		mDao.updateIntegralCardScore(dto);
	}
	
	
	/**
	 * 
	 * @param id
	 * @throws TmsDaoException
	 */
	public void lockMemberForUpdate(int id) throws TmsDaoException{
		((MemberDao) TmsDao.getInstance(TmsDao.TMS_MEMBER)).lockMemberForUpdate(id);
	}
	
	
	/**
	 * 
	 * @param MemId
	 * @param usedCarPort
	 * @param updateUserId
	 * @throws TmsDaoException
	 */
	public void updateUsedCarPort(int memberId,int usedCarPort, int increment,int updateUserId,String reason) throws TmsDaoException{
		logger.info("Change UsedCarPort,memberId:"+memberId+" before usedCarPort:"+usedCarPort +" increment:"+increment +" reason"+reason);
		//
		MemberDao mDao = (MemberDao) TmsDao.getInstance(TmsDao.TMS_MEMBER);
		MemberDto dto = new MemberDto();
		dto.setMemId(memberId);
		dto.setUpdateUserId(updateUserId);
		mDao.updateUsedCarPort(dto,increment);
	}
	/**
	 * 
	 * @param MemId
	 * @param usedCarPort
	 * @throws TmsDaoException
	 */
	public void updateUsedCarPort(int memberId,int usedCarPort, int increment,String reason) throws TmsDaoException{
		updateUsedCarPort(memberId,usedCarPort,increment,TmsConstants.SYSTEM_OPERATOR_ID,reason);
	}

	/**
	 * 更新合同编号List
	 * @param member
	 * @throws TmsDaoException
	 */
	public void updateMemberBusinessNoInfo(Member member) throws TmsDaoException{
		MemberDao mDao = (MemberDao) TmsDao.getInstance(TmsDao.TMS_MEMBER);
		MemberDto dto = new MemberDto();
		dto.setMemId(member.getMemId());
		dto.setBusinessNo(member.getBusinessNo());
		dto.setUpdateUserId(member.getUpdateUserId());
		dto.setFloors(member.getFloors());
		mDao.updateMemberBusinessNoInfo(dto);
	}

	/**
	 * 更新member信息
	 * @param member
	 * @throws TmsDaoException
	 */
	public void updateMemberInfo(Member member) throws TmsDaoException{
		MemberDao mDao = (MemberDao) TmsDao.getInstance(TmsDao.TMS_MEMBER);
		MemberDto dto = new MemberDto();
		dto.setMemId(member.getMemId());
		dto.setAnnualTransactionVolume(member.getAnnualTransactionVolume());
		dto.setCarPort(member.getCarPort());
		dto.setFragileStickerFreePort(member.getFragileStickerFreePort());
		dto.setRecommend(member.getRecommend());
		dto.setUpdateUserId(member.getUpdateUserId());
		dto.setIdentityRange(member.getIdentityRange());
		dto.setTmpIdentityRange(member.getTmpIdentityRange());
		dto.setContractType(member.getContractType());
		if(StringUtil.isNotBlank(member.getContractTime())) dto.setContractTime(DateUtil.getStringToTimeStamp1(member.getContractTime()+" 00:00:00"));
		mDao.updateMemberInfo(dto);
	}
	
	
	/**
	 * 根据memberID查询允许库存登记数量
	 * 
	 * @return
	 * @throws TmsDaoException     
	 */
	public int findAnnualTransactionVolume(String memberId) throws TmsDaoException
	{
		int annualTransactionVolume = 0;
		MemberDao mDao = (MemberDao) TmsDao.getInstance(TmsDao.TMS_MEMBER);
		annualTransactionVolume = mDao.findAnnualTransactionVolume(memberId);
		
		return annualTransactionVolume;
	}
	
	
	/**
	 * 查找商户名称
	 * @param memberName
	 * @param flag
	 * @throws TmsDaoException
	 */
	public List<Member> findMemberNameList(String memberName,int flag) throws TmsDaoException{
		MemberDao mDao = (MemberDao) TmsDao.getInstance(TmsDao.TMS_MEMBER);
		List<MemberDto> dtoList = mDao.findMemberNameList(memberName,flag);
		List<Member> mInfoList = new ArrayList<Member>();
		
		if (null != dtoList && dtoList.size() > 0) {
			
			for (int i = 0; i < dtoList.size();i++) {
				Member mInfo= new Member();
				mInfo = getEntityFromDto(dtoList.get(i));
				mInfoList.add(mInfo);
			}
		}
		return mInfoList;
	}
	/**
	 * @param dto
	 * @throws TmsDaoException
	 */
	private Member getEntityFromDto(MemberDto dto){
		Member mem = new Member();
		mem.setShortName(dto.getShortName());
		mem.setRealNamePy(dto.getRealNamePy());
		mem.setMemId(dto.getMemId());
		return mem;		
	}
	
	public int getMemId() {
		return memId;
	}

	public void setMemId(int memId) {
		this.memId = memId;
	}

	public String getMemName() {
		return memName;
	}

	public void setMemName(String memName) {
		this.memName = memName;
	}

	public String getRealName() {
		return realName;
	}

	public void setRealName(String realName) {
		this.realName = realName;
	}

	public String getAdrress() {
		return adrress;
	}

	public void setAdrress(String adrress) {
		this.adrress = adrress;
	}

	public String getMemberZipCode() {
		return memberZipCode;
	}

	public void setMemberZipCode(String memberZipCode) {
		this.memberZipCode = memberZipCode;
	}
	public String getOrgNo() {
		return orgNo;
	}

	public void setOrgNo(String orgNo) {
		this.orgNo = orgNo;
	}

	public String getBusinessNo() {
		return businessNo;
	}

	public void setBusinessNo(String businessNo) {
		this.businessNo = businessNo;
	}

	public String getContactOwner() {
		return contactOwner;
	}

	public void setContactOwner(String contactOwner) {
		this.contactOwner = contactOwner;
	}

	public String getContactPhone() {
		return contactPhone;
	}

	public void setContactPhone(String contactPhone) {
		this.contactPhone = contactPhone;
	}

	public String getLegal() {
		return legal;
	}

	public void setLegal(String legal) {
		this.legal = legal;
	}

	public String getPhone() {
		return phone;
	}

	public void setPhone(String phone) {
		this.phone = phone;
	}

	public String getCardNo() {
		return cardNo;
	}

	public void setCardNo(String cardNo) {
		this.cardNo = cardNo;
	}

	public int getRegisteredCapital() {
		return registeredCapital;
	}

	public void setRegisteredCapital(int registeredCapital) {
		this.registeredCapital = registeredCapital;
	}

	public int getOperatingLife() {
		return operatingLife;
	}

	public void setOperatingLife(int operatingLife) {
		this.operatingLife = operatingLife;
	}

	public int getOfficeSpaceArea() {
		return officeSpaceArea;
	}

	public void setOfficeSpaceArea(int officeSpaceArea) {
		this.officeSpaceArea = officeSpaceArea;
	}

	public int getAnnualTransactionVolume() {
		return annualTransactionVolume;
	}

	public void setAnnualTransactionVolume(int annualTransactionVolume) {
		this.annualTransactionVolume = annualTransactionVolume;
	}


	public String getMargin() {
		return margin;
	}

	public void setMargin(String margin) {
		this.margin = margin;
	}

	public String getVirtualMargin() {
		return virtualMargin;
	}

	public void setVirtualMargin(String virtualMargin) {
		this.virtualMargin = virtualMargin;
	}

	public String getOrgPhoto() {
		return orgPhoto;
	}

	public void setOrgPhoto(String orgPhoto) {
		this.orgPhoto = orgPhoto;
	}

	public String getBusinessPhoto() {
		return businessPhoto;
	}

	public void setBusinessPhoto(String businessPhoto) {
		this.businessPhoto = businessPhoto;
	}

	
	
	public int getGiftMargin() {
		return giftMargin;
	}

	public void setGiftMargin(int giftMargin) {
		this.giftMargin = giftMargin;
	}

	public int getRealMargin() {
		return realMargin;
	}

	public String getContractTime() {
		return contractTime;
	}

	public void setContractTime(String contractTime) {
		this.contractTime = contractTime;
	}

	public void setRealMargin(int realMargin) {
		this.realMargin = realMargin;
	}

	public String getCardPhoto() {
		return cardPhoto;
	}

	public void setCardPhoto(String cardPhoto) {
		this.cardPhoto = cardPhoto;
	}

	public List<Member> getCodes() {
		return codes;
	}

	public void setCodes(List<Member> codes) {
		this.codes = codes;
	}

	public String getUserId() {
		return userId;
	}

	public void setUserId(String userId) {
		this.userId = userId;
	}

	public int getUpdateUserId() {
		return updateUserId;
	}

	public void setUpdateUserId(int updateUserId) {
		this.updateUserId = updateUserId;
	}

	public String getMemberStatus() {
		return memberStatus;
	}

	public void setMemberStatus(String memberStatus) {
		this.memberStatus = memberStatus;
	}

	public int getCssFlag() {
		return cssFlag;
	}

	public void setCssFlag(int cssFlag) {
		this.cssFlag = cssFlag;
	}

	public int getSpacesNo() {
		return spacesNo;
	}

	public void setSpacesNo(int spacesNo) {
		this.spacesNo = spacesNo;
	}

	public int getCarPort() {
		return carPort;
	}

	public void setCarPort(int carPort) {
		this.carPort = carPort;
	}

	public int getUsedCarPort() {
		return usedCarPort;
	}

	public void setUsedCarPort(int usedCarPort) {
		this.usedCarPort = usedCarPort;
	}

	public String getAccessCardId() {
		return accessCardId;
	}

	public void setAccessCardId(String accessCardId) {
		this.accessCardId = accessCardId;
	}

	public String getFloors() {
		return floors;
	}

	public void setFloors(String floors) {
		this.floors = floors;
	}

	public String getCarPortInstr() {
		return carPortInstr;
	}

	public void setCarPortInstr(String carPortInstr) {
		this.carPortInstr = carPortInstr;
	}

	public String getAccessCardNo() {
		return accessCardNo;
	}

	public void setAccessCardNo(String accessCardNo) {
		this.accessCardNo = accessCardNo;
	}

	public int getCardScore() {
		return cardScore;
	}

	public void setCardScore(int cardScore) {
		this.cardScore = cardScore;
	}

	public String getSettleName() {
		return settleName;
	}

	public void setSettleName(String settleName) {
		this.settleName = settleName;
	}

	public String getSettleNo() {
		return settleNo;
	}

	public void setSettleNo(String settleNo) {
		this.settleNo = settleNo;
	}

	public String getSettlePhone() {
		return settlePhone;
	}

	public void setSettlePhone(String settlePhone) {
		this.settlePhone = settlePhone;
	}

	public int getInsertUserId() {
		return insertUserId;
	}

	public void setInsertUserId(int insertUserId) {
		this.insertUserId = insertUserId;
	}
	
	public double getIntegralRatio() {
		return integralRatio;
	}

	public void setIntegralRatio(double integralRatio) {
		this.integralRatio = integralRatio;
	}

	public String getShortName() {
		return shortName;
	}

	public void setShortName(String shortName) {
		this.shortName = shortName;
	}

	public String getRecommend() {
		return recommend;
	}

	public void setRecommend(String recommend) {
		this.recommend = recommend;
	}

	public int getFragileStickerFreePort() {
		return fragileStickerFreePort;
	}

	public void setFragileStickerFreePort(int fragileStickerFreePort) {
		this.fragileStickerFreePort = fragileStickerFreePort;
	}

	public void setRealNamePy(String realNamePy) {
		this.realNamePy = realNamePy;
	}

	public String getRealNamePy() {
		return realNamePy;
	}

	public void setInsertTime(String insertTime) {
		this.insertTime = insertTime;
	}

	public int getContractType() {
		return contractType;
	}

	public void setContractType(int contractType) {
		this.contractType = contractType;
	}

	public String getInsertTime() {
		return insertTime;
	}

	public void setNum(String num) {
		this.num = num;
	}

	public String getNum() {
		return num;
	}

	/**
	 * @param memStatus the memStatus to set
	 */
	public void setMemStatus(int memStatus) {
		this.memStatus = memStatus;
	}

	/**
	 * @return the memStatus
	 */
	public int getMemStatus() {
		return memStatus;
	}

	public String getIdentityRange() {
		return identityRange;
	}

	public void setIdentityRange(String identityRange) {
		this.identityRange = identityRange;
	}

	public void setTmpIdentityRange(String tmpIdentityRange) {
		this.tmpIdentityRange = tmpIdentityRange;
	}

	public String getTmpIdentityRange() {
		return tmpIdentityRange;
	}

    public int getFreeCarPort() {
        return freeCarPort;
    }

    public void setFreeCarPort(int freeCarPort) {
        this.freeCarPort = freeCarPort;
    }
	
	
}
